"""
@Author  : 康帅
@Time    : 2021/2/6 13:32
@Function: 根据读取文件获取移动方位坐标
"""


class Position:
    @staticmethod
    def read_file():
        with open('example1.txt') as f:
            content = f.read().strip().split("\n")
        contents = [i.split() for i in content]
        return contents

    @staticmethod
    def search_position(data):
        x = 0
        y = 0
        for p in data:
            d = (','.join(p))
            for i in d:
                if i == "N":
                    y += 1
                elif i == "E":
                    x += 1
                elif i == "S":
                    y -= 1
                elif i == "W":
                    x -= 1
            return x, y


if __name__ == '__main__':
    data = Position.read_file()
    for i in data:
        print(Position.search_position(i))
